Tuesday 24 June 2014

Creating Navigation Bar with Green Theme and a drop -down feature

My Green Navigation Bar 

The markup
 
<!Doctype html>
<html>
<head>
<title>My Green Navigation Bar</title>
<link rel ="stylesheet" href ="tell.css">
</head>

<body>
    <div class ="tell">
<ul id = "navigation">
    <li><a href="">Home</a>
        <ul>
        <li><a href="">Gold</a></li>
        <li><a href="">Platinum</a></li>
        </ul>
    </li>
     <li><a href="">Mail</a></li>
     <li><a href="">Cars</a></li>
     <li><a href="">Doll</a></li>
</ul>
  </div>
</body>
</html>

The Stylesheet
.tell{
background-color: green;
height: 50px;
position: relative;
z-index: 99;
}

#navigation{
height: 50px;
    position: absolute;
    margin: 0;
    padding: 0;
    border-right: 1px solid #58bf21;
}
#navigation li{
background-color: #58bf21;
margin: 0;
float: left;
list-style: none;
width: 200px;
text-align: center;
}
#navigation a{
color: white;
font-family: Tahoma;
text-decoration: none;
border-left: 1px solid green;
padding: 18px 0;
display: block;
}

#navigation li:hover, a:hover{
background-color: green;
}
#navigation li ul{
display: none;
margin: 0;
padding: 0;
}
#navigation li:hover ul {
display: block;
}
#navigation li ul li a:hover{
background-color: green;
}




Saturday 10 May 2014

Receipt issuing Application in plain C++(console);

/*
Author:   Gideon Asare
Product:  Shop receipt prog
Language: c-pluplus
Contact:  kofiowusu847@gmail.com
blog:     http://quickerprogramming.blogspot.com

*/
/*---------------------------------------------------------------------------------------------------------------*/

#include <iostream>     //this file is responsible for input and output of data
#include <ctime>            // it contains time elements */
#include <fstream>         //  fstream means file stream and its a library use to write to files in c++. it helps create files */

using namespace std;         // the namespace std preprocessors enables the program to use c++ standard   library


class timeteller{

public:
    void screenprompts();
    void date_and_time();
};

void timeteller::date_and_time(){
time_t currentime = time(0);
char* dt =ctime(&currentime);
cout << dt << endl;
}
void timeteller::screenprompts(){
cout << "Use the Tap key to space" << endl;
 cout << "Press CTR Z to quit " << endl;
 cout <<"you can tap twice if not align for the first entry only\n" << endl;
}

static  string product;                          //static variables are always outside any function or class
static double amount;
static unsigned int quantity;


class sales{
private:
                                                            // variable that are accessed only by the sales class
    string Productname;
    string numbersold;
    string currency;
    string total;
public:
                                                        //prototypes of the functions for the sales class
    sales(timeteller obj);
    void head(string Pro,string Qt, string cu,string tot);
    void  main_heading();
    double productprice();
    string getpro();
    string getcurrency();
    string getnumbersold();
    string gettotal();
};
    sales::sales(timeteller obj){ // passing the timeller class object to sales constructor;
        obj.screenprompts();       // using the object to access the functions of timeteller

    }

    //
    void sales::head(string Pro,string Qt, string cu,string tot){
    Productname = Pro, numbersold = Qt, currency = cu, total = tot;
    ofstream thefile("receipt.txt");
    thefile << Productname <<"\t" << numbersold << "\t" <<currency <<"\t" << total << endl;
    }

    //these similar functions returns the variables
    string sales::getpro(){
    return Productname; // return the variable; Productname;
    }

    string sales::getnumbersold(){
        return numbersold;// return the variable numbersold;
    }

    string sales::getcurrency(){
        return currency;
    }

    string sales::gettotal(){
        return total;
    }


    // the function sales is basically doing the calculations

    double sales::productprice(){                                                               /*  */
    ofstream thefile("receipt.txt");
    string header = " SUBA SHOPPING CENTRE\n P.O.BOX 40\n AMERICAN HOUSE\n EAST LEGON ACCRA\n ";
    thefile << header;

    cout << header << endl;

    cout << "----------------------------------" << endl;       // horizontal line to the user
    cout << "ProName    ""  Quantity""  Amount"<<endl;
    thefile<< "----------------------------------\n";         // horizontal  line to the file
    double finaltotal = 0 ;
                                                                // this is the grand total variable
    while(cin>> product >> quantity >> amount){

        double subtotal = 0;                                // the subtotal variable and initialized to 0;

        subtotal = quantity * amount ;                      //
        finaltotal += subtotal;                              // the sum of subtotal is grand total

        /* this line writes to thefile created that txt file is name receipt.txt*/
        thefile << product <<"\t"<< quantity <<"\t"<< amount<<"\t"<< subtotal<< endl;
    }
                                                            // formatting on the txt file.
     thefile << "\t\t\t\tGrand Total" << endl;
     thefile << "\t\t\t\tGhc" <<  finaltotal;
    }

/* Execution of the functions at main*/
/* standard c++ simplifies the main function by not explicitly using argv[] argc parameters*/
int main()
{
     timeteller tim;
    sales on(tim);
    tim.date_and_time();
    on.head("Prod","Qty","Amt","Total");
    on.productprice();

    return 0;
}